package values.tech
{
import core.Configuration;
import core.Language;

/**
 * TechTemplateValue
 * @author jliang
 *
 */
public class TechTemplateValue
{
	[Data(type="field", mapping="@index")]
	public var index:int;
	
	[Data(type="field", mapping="@key")]
	public var key:String;
	
	[Data(type="field", mapping="@name")]
	public var baseNameKey:String;
	
	public function get name():String
	{
		return Language.getText(baseNameKey);
	}
	
	[Data(type="field", mapping="@desc")]
	public var baseDescKey:String;
	
	public function get desc():String
	{
		return Language.getText(baseDescKey);
	}
	
	[Data(type="field", mapping="@icon")]
	public var baseIconPath:String;
	
	public function get icon():String
	{
		return Configuration.assetsPath + baseIconPath;
	}
	
	protected var _requirements:TechRequirementValue;
	
	public function get requirements():TechRequirementValue
	{
		return _requirements;
	}
	
	[Data(type="mapping", 
			   mapping="requirements", 
			   ref="values.tech.TechRequirementValue",
			   way="own")]
	public function set requirements(value:TechRequirementValue):void
	{
		_requirements = value;
	}
	
	protected var _levels:Array; /* TechLevelValue */
	
	public function get levels():Array
	{
		return _levels;
	}
	
	[Data(type="mapping", 
		  mapping="levels.level", 
		  ref="values.tech.TechLevelValue",
		  way="one_to_more")]
	public function set levels(value:Array):void
	{
		_levels = value;
	}
	
	public function getLevel(lvl:int):TechLevelValue
	{
		return levels[lvl - 1];
	}
}
}






